package com.damin;

import com.alibaba.fastjson.JSON;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public abstract class Sort<T extends Comparable<T>> {

    protected Logger logger = LoggerFactory.getLogger(getClass());

    public abstract void sort(T[] nums);

    protected boolean less(T v, T w) {
        return v.compareTo(w) < 0;
    }

    protected void swap(T[] a, int i, int j) {
        T t = a[i];
        a[i] = a[j];
        a[j] = t;
        logger.info("交换{}:{}和{}:{}.{}", i, a[i], j, a[j], JSON.toJSONString(a));
    }
}
